package com.example.shaoying.yuejian.fragment.clubeFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.shaoying.yuejian.R;
import com.example.shaoying.yuejian.adapter.ClubListAdapter;
import com.example.shaoying.yuejian.javabean.ClubInfo;
import com.example.shaoying.yuejian.javabean.ClubList;
import com.example.shaoying.yuejian.model.ClubeModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;


public class ClubeJieShaoFragment extends Fragment {

    private TextView Club_Info_Name;
    private TextView Club_Info_Tel;
    private TextView Club_Info_Address;
    private TextView Club_Info_Time;
    private Retrofit retrofit;
    private String Club_Id;
    private ClubInfo clubInfo;
    private View view;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view=inflater.inflate(R.layout.clube_jieshao, container, false);
        Club_Info_Name= (TextView) view.findViewById(R.id.club_info_name);
        Club_Info_Tel= (TextView) view.findViewById(R.id.club_info_tel);
        Club_Info_Time= (TextView) view.findViewById(R.id.club_info_time);
        Club_Info_Address= (TextView) view.findViewById(R.id.club_info_address);

        Club_Id=getActivity().getIntent().getStringExtra("Club_Id");

       ClubeModel model=new ClubeModel();
       Call<ClubInfo> call=model.getClubeInfo(Club_Id);
        call.enqueue(new Callback<ClubInfo>() {
            @Override
            public void onResponse(Call<ClubInfo> call, Response<ClubInfo> response) {
                clubInfo=response.body();
                Club_Info_Name.setText(clubInfo.getIntroduction());
                Club_Info_Tel.setText(clubInfo.getClub_tel());
                Club_Info_Time.setText(clubInfo.getOpen_time());
                Club_Info_Address.setText(clubInfo.getDistrict_name());
            }
            @Override
            public void onFailure(Call<ClubInfo> call, Throwable t) {

                Toast.makeText(getActivity(),"获取俱乐部信息失败",Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    }


}
